﻿<Window 
    x:Class="Foggy.Views.SettingsView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro" mc:Ignorable="d" 
    Width="400"
    Height="500"
    WindowStyle="SingleBorderWindow"
    WindowStartupLocation="CenterOwner"
    ResizeMode="NoResize"
    d:DesignHeight="300" d:DesignWidth="300">

    <Grid Margin="10">

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="10" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="10" />
            <RowDefinition Height="*" />
            <RowDefinition Height="10" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Grid Grid.Row="0">

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="10" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="10" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="10" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="10" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <Label Grid.Column="0" Grid.Row="0">FogbugzUrl</Label>
            <TextBox Grid.Column="2" Grid.Row="0" x:Name="FogBugzUrl" />

            <Label Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="2" x:Name="FogBugzApiUrl" />

            <Label Grid.Column="0" Grid.Row="4">Login Username</Label>
            <TextBox Grid.Column="2" Grid.Row="4" x:Name="LoginUsername" />

            <Label Grid.Column="0" Grid.Row="6">Login Password</Label>
            <TextBox Grid.Column="2" Grid.Row="6" x:Name="LoginPassword" />

        </Grid>

        <Label Grid.Row="2">Users</Label>

        <Grid Grid.Row="3">

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="10" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <TextBox x:Name="NewUserEmail" Grid.Column="1" Width="200" />
            <Button x:Name="AddUser" Grid.Column="3">Add</Button>

        </Grid>

        <ListBox 
            Grid.Row="5" 
            ItemsSource="{Binding Users}" 
            SelectedItem="{Binding SelectedUser}"
            HorizontalContentAlignment="Stretch">

            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>

                        <TextBox Grid.Column="0" Text="{Binding Email}" />
                        <Button Grid.Column="1" cal:Message.Attach="[Event Click] = [Action DeleteUser($dataContext)]">Delete</Button>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>

        </ListBox>

        <Grid Grid.Row="7">

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="10" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <Button Grid.Column="1" x:Name="Cancel">Cancel</Button>
            <Button Grid.Column="3" x:Name="Ok">Ok</Button>

        </Grid>

    </Grid>

</Window>